﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace zielonka.co.uk.extensions.system
{
    //Description:	Reduces the length of a string to toLength and adds an additional string to the end of the shortened string to denote that the string was shortened (Default ...)
    /*
        
    */

    public static partial class StringExtensions
    {
        public static string Shorten(this string str, int toLength, string cutOffReplacement = " ...")
        {
            if (string.IsNullOrEmpty(str) || str.Length <= toLength)
                return str;
            
            return str.Remove(toLength) + cutOffReplacement;
        }
    }
}
